package com.example.project01.api;

import com.example.project01.service.BannerService;
import com.leon.model.Pageable;
import com.leon.web.annotation.ApiAuth;
import com.leon.web.annotation.ApiLogger;
import com.leon.web.annotation.ApiSetting;
import com.leon.web.annotation.Condition;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("/app")
public class AppBannerApi {

    private final BannerService bannerService;

    @GetMapping("/banner")
    @Operation(summary = "banners", description = "获取APP首页Banner")
    @ApiSetting(log = @ApiLogger(print = true), auth = @ApiAuth(condition = Condition.SESSION))
    public ResponseEntity<?> listBanners(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                         @RequestParam(value = "size", defaultValue = "20") Integer size) {
        return ResponseEntity.ok().body(bannerService.bannersList(Pageable.of(page, size)));
    }


}
